package com.ww.learn.collection

// 创建不可变列表，使用listOf()
// 创建可变列表，mutableListOf()

fun main() {
    val fruits: List<String> = listOf("Apple", "Banana", "Grape")
    println(fruits)

    // 报错
    //  Unresolved reference 'add'.
//    fruits.add("Orange")

    // +运算符
    val fruits2 = fruits + "Orange"
    // [Apple, Banana, Grape]
    println(fruits)
    // [Apple, Banana, Grape, Orange]
    println(fruits2)

    // -运算符
    val noBanana = fruits - "Banana"
//    [Apple, Banana, Grape]
    println(fruits)
//    [Apple, Grape]
    println(noBanana)

    val fruit2s: MutableList<String> = mutableListOf("Apple", "Banana", "Grape")
    println(fruit2s::class)
    fruit2s.add("Orange")
}